/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.diplomka.webapp.resource;

import cz.fi.muni.diplomka.common.enumeration.ResourceType;
import cz.muni.fi.diplomka.servicelayer.gamelogic.manager.CityManager;
import cz.muni.fi.diplomka.servicelayer.gamelogic.manager.CityResourcesManager;
import cz.muni.fi.diplomka.servicelayer.gamelogic.managerimpl.CityManagerImpl;
import cz.muni.fi.diplomka.servicelayer.gamelogic.managerimpl.CityResourcesManagerImpl;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.resource.ContextRelativeResource;

/**
 *
 * @author Jakub Kutil
 */
public class ResourcesPanel extends Panel {

    private CityResourcesManager cityResourcesManager = new CityResourcesManagerImpl();
    private CityManager cityManager = new CityManagerImpl();

    public ResourcesPanel(String id, PageParameters parameters) {
        super(id);

        if (parameters.containsKey("cityName")) {
            String cityName = parameters.getString("cityName");

            add(new Label("city", " City: " + cityManager.getCityByName(cityName).getName()+ " "));
            add(new Image("arms", new ContextRelativeResource("/images/arms/arms-" + cityManager.getOwnerOfCity(cityManager.getCityByName(cityName).getId()).getColor().toString() + ".png")));
            add(new Image("arms2", new ContextRelativeResource("/images/arms/arms-" + cityManager.getOwnerOfCity(cityManager.getCityByName(cityName).getId()).getColor().toString() + ".png")));
            add(new Label("food", "Food: " + cityResourcesManager.getResourceCount(cityManager.getCityByName(cityName).getId(), ResourceType.Food)+ " "));
            add(new Image("foodImage", new ContextRelativeResource("/images/resource/food.png")));
            add(new Label("gold", "Gold: " + cityResourcesManager.getResourceCount(cityManager.getCityByName(cityName).getId(), ResourceType.Gold)+ " "));
            add(new Image("goldImage", new ContextRelativeResource("/images/resource/gold.png")));
            add(new Label("stone", "Stone: " + cityResourcesManager.getResourceCount(cityManager.getCityByName(cityName).getId(), ResourceType.Stone)+ " "));
            add(new Image("stoneImage", new ContextRelativeResource("/images/resource/stone.png")));
        }
    }
}
